package cn.gok.util;

import cn.hutool.cache.CacheUtil;
import cn.hutool.cache.impl.TimedCache;
import com.sun.applet2.AppletParameters;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.HashMap;

/**
 * @author: 鸭鸭
 * @ClassName:UserCacheManager
 * @Package:cn.gok.util
 * @Description:
 * @date: 2021/8/4
 * @time: 19:47
 */
public class UserCacheManager {

    private static TimedCache<String, String> timedCache = CacheUtil.newTimedCache(60000);
    /**
     * 添加用户信息缓存
     * @param sessionId
     * @param
     * @return
     */
    public static boolean addCache(String sessionId,String token){
        timedCache.put(sessionId, token);//默认过期时间
        return true;
    }

    /**
     * 定时清除用户缓存信息
     * @param
     * @return
     */
    public static boolean delCache(){
        timedCache.schedulePrune(5);
        return true;
    }

    /**
     * 获取用户缓存信息
     * @param sessionId
     * @return
     */
    public static String getCache(String sessionId){
        return timedCache.get(sessionId,false);
    }

    /*
    *
    * */



}
